package cn.bsb.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import cn.bsb.pojo.Bookmark;

public interface BookMapper {
	@Insert(" INSERT INTO bookmark (dev_user_id,article_id,`time`) VALUES (#{dev_user_id},#{article_id},#{time})")
	public int addBook(Bookmark book);
	
	@Select("SELECT * FROM bookmark WHERE dev_user_id =#{vid} AND article_id=#{aid}")
	public Bookmark isBookmark(@Param("vid")Long vid,@Param("aid")Long aid);
	
	@Delete("DELETE  FROM `bookmark` WHERE dev_user_id =#{vid} AND article_id	=#{aid} ")
	public int deBookMark(@Param("vid")Long vid,@Param("aid")Long aid);
	
	@Select("SELECT *,(SELECT title FROM article WHERE article.id=bookmark.article_id) AS title FROM bookmark WHERE dev_user_id = #{vid}")
	public List<Bookmark> getBookList(@Param("vid")long id);
	
}
